<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\RechargeBlacklist;

class RechargeBlacklistController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new RechargeBlacklist();
    }

    //目前平台使用中的充值方式
    public function nowAppPayList(){
        $nowUseList = [
            [
                'name' => '三方微信',
                'type' => 9,
            ],
            [
                'name' => '三方支付宝',
                'type' => 10
            ]
        ];
        return $this->toJson(self::SUCCESS,$nowUseList);
    }

    //充值黑名单列表
    public function rechargeBlackList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->rechargeBlackList($request));
    }

    //充值黑名单新增
    public function rechargeBlackAdd(Request $request){
        $res = $this->model->rechargeBlackAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::NUMBER, '充值黑名单新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //充值黑名单删除
    public function rechargeBlackDel(Request $request){
        $res = $this->model->rechargeBlackDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::NUMBER, '充值黑名单删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }
    
    //短时间充值黑名单新增
    public function shortRechargeBlackAdd(Request $request){
        $res = $this->model->shortRechargeBlackAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::NUMBER, '临时充值黑名单新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //短时间充值黑名单删除
    public function shortRechargeBlackDel(Request $request){
        $res = $this->model->shortRechargeBlackDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::NUMBER, '临时充值黑名单删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //短时间充值黑名单列表
    public function shortRechargeBlackList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $user_id = $request->get('user_id',0);
        $status = $request->get('status',2);//默认2全部
        $res = $this->model->shortRechargeBlackList($page, $limit, $user_id, $status);
        return $this->toJson(self::SUCCESS, $res);
    }

}
